﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using SipII.Parameter;

namespace SipII.Message
{

    /// <summary>
    /// 消息类基类
    /// </summary>
    public class MessageBase
    {
        protected StringBuilder sb = new StringBuilder();

        /// <summary>
        /// Message
        /// </summary>
        protected string message;

        /// <summary>
        /// 命令序号
        /// </summary>
        protected char sequence;

        /// <summary>
        /// 命令序号
        /// </summary>
        public char Sequence
        {
            set { sequence = value; }
            get { return sequence; }
        }

        /// <summary>
        /// 是否启用了错误检测
        /// </summary>
        protected bool errorDetectionEnable;

        /// <summary>
        /// 是否启用了错误检测,只读属性
        /// </summary>
        public bool ErrorDetectionEnable
        {
            get { return errorDetectionEnable; }
        }

        /// <summary>
        /// 做初步的解析操作
        /// </summary>
        /// <param name="_message"></param>
        protected void Parse(string _message)
        {
            message = _message;

            //是否启用了错误检测
            errorDetectionEnable = Regex.IsMatch(message, "AZ[0-9a-fA-F]{4}\\n");

            if (errorDetectionEnable)
            {
                sequence = message.Substring(message.Length - 8, 1).ToCharArray()[0];
            }
        }

        /// <summary>
        /// 检测可选字段是否存在
        /// </summary>
        /// <param name="fieldId"></param>
        /// <returns></returns>
        protected bool OptionFieldIsExist(string fieldId)
        {
            return Regex.IsMatch(message, "\\|" + fieldId);
        }

        /// <summary>
        /// 解析字段的值
        /// </summary>
        /// <param name="fieldId"></param>
        /// <returns></returns>
        protected string ParseFieldValue(string fieldId, bool isFirstField)
        {
            if (isFirstField)
            {
                return Regex.Match(message, string.Format("(?<={0})[^\\|]*", fieldId)).Value;
            }
            else
            {
                return OptionFieldIsExist(fieldId) ? Regex.Match(message, string.Format("(?<=\\|{0})[^\\|]*", fieldId)).Value : "";
            }
        }

        /// <summary>
        /// 解析字段组的值
        /// </summary>
        /// <param name="fieldId"></param>
        /// <returns></returns>
        protected List<string> ParseFieldValueList(string fieldId)
        {
            List<string> result = new List<string> { };

            foreach (Match item in Regex.Matches(message, string.Format("(?<=\\|{0})[^\\|]*", fieldId)))
            {
                result.Add(item.Value);
            }

            return result;
        }


        /// <summary>
        /// 添加必备字段
        /// </summary>
        /// <param name="fieldName">字段名称</param>
        /// <param name="fieldValue">字段值</param>
        protected void Append(string fieldName, object fieldValue)
        {
            if (fieldValue != null)
            {
                if (fieldValue.GetType().Name.ToLower() == "string")
                {
                    if (fieldValue == null)
                    {
                        fieldValue = "";
                    }
                }

                sb.Append(fieldName);
                sb.Append(fieldValue);
                sb.Append(Properties.Settings.Default.FieldDelimiter);
            }
        }

        /// <summary>
        /// 添加可选字段
        /// </summary>
        /// <param name="fieldName">字段名称</param>
        /// <param name="fieldValue">字段值</param>
        protected void AppendOptional(string fieldName, string fieldValue)
        {
            if (!string.IsNullOrEmpty(fieldValue))
            {
                sb.Append(fieldName);
                sb.Append(fieldValue);
                sb.Append(Properties.Settings.Default.FieldDelimiter);
            }
        }

        /// <summary>
        /// 添加可选字段
        /// </summary>
        /// <param name="fieldName">字段名称</param>
        /// <param name="fieldValueArray">字段值</param>
        protected void AppendOptional(string fieldName, List<string> fieldValueList)
        {
            if (fieldValueList != null)
            {
                if (Properties.Settings.Default.JoinFeilds)
                {
                    string fieldValues = "";

                    foreach (string fieldValue in fieldValueList)
                    {
                        if (!string.IsNullOrEmpty(fieldValue))
                        {
                            fieldValues = fieldValues == "" ? fieldValue : fieldValues + "," + fieldValue;                            
                        }
                    }

                    if (!string.IsNullOrEmpty(fieldValues))
                    {
                        sb.Append(fieldName);
                        sb.Append(fieldValues);
                        sb.Append(Properties.Settings.Default.FieldDelimiter);
                    }
                }
                else
                {
                    foreach (string fieldValue in fieldValueList)
                    {
                        if (!string.IsNullOrEmpty(fieldValue))
                        {
                            sb.Append(fieldName);
                            sb.Append(fieldValue);
                            sb.Append(Properties.Settings.Default.FieldDelimiter);
                        }
                    }
                }
            }
        }

        /// <summary>
        /// 添加可选字段
        /// </summary>
        /// <param name="fieldName">字段名称</param>
        /// <param name="fieldValue">字段值</param>
        protected void AppendOptional(string fieldName, char fieldValue)
        {
            if (fieldValue != '\0')
            {
                sb.Append(fieldName);
                sb.Append(fieldValue);
                sb.Append(Properties.Settings.Default.FieldDelimiter);
            }
        }

        /// <summary>
        /// 添加可选字段
        /// </summary>
        /// <param name="fieldName">字段名称</param>
        /// <param name="fieldValue">字段值</param>
        protected void AppendOptional(string fieldName, char[] fieldValue)
        {
            if (fieldValue[0] != '\0' || fieldValue[fieldValue.Length - 1] != '\0')
            {
                sb.Append(fieldName);
                sb.Append(fieldValue);
                sb.Append(Properties.Settings.Default.FieldDelimiter);
            }
        }
    }

    /// <summary>
    /// 登录消息[93]
    /// </summary>
    public class Login : MessageBase
    {
        private char uidAlgorithm;

        public char UidAlgorithm
        {
            set { uidAlgorithm = value; }
            get { return uidAlgorithm; }
        }

        private char pwdAlgorithm;

        public char PwdAlgorithm
        {
            get { return pwdAlgorithm; }
            set { pwdAlgorithm = value; }
        }

        private string loginUserId;

        public string LoginUserId
        {
            get { return loginUserId; }
            set { loginUserId = value; }
        }
        private string loginPassword;

        public string LoginPassword
        {
            get { return loginPassword; }
            set { loginPassword = value; }
        }

        private string locationCode;

        public string LocationCode
        {
            get { return locationCode; }
            set { locationCode = value; }
        }

        public Login() { }

        public Login(string _message)
        {
            base.Parse(_message);

            //解析数据
            uidAlgorithm = message[2];
            pwdAlgorithm = message[3];

            loginUserId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.login_user_id.ToString()], true);
            loginPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.login_password.ToString()], false);
            locationCode = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.location_code.ToString()], false);
        }

        /// <summary>
        /// 构造Message
        /// </summary>
        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.Login));

            sb.Append(uidAlgorithm);
            sb.Append(pwdAlgorithm);

            Append(Sip2Parameter.dicFieldId[enumFieldName.login_user_id.ToString()], loginUserId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.login_password.ToString()], loginPassword);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.location_code.ToString()], locationCode);

            message = sb.ToString();
        }

        /// <summary>
        /// 返回该对象的字符串表示形式
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 登录回复消息[94]
    /// </summary>
    public class LoginResponse : MessageBase
    {
        private char ok;

        public char Ok
        {
            set { ok = value; }
            get { return ok; }
        }

        public LoginResponse() { }

        public LoginResponse(string _message)
        {
            base.Parse(_message);

            //解析数据
            ok = message[2];
        }

        /// <summary>
        /// 构造Message
        /// </summary>
        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.LoginResponse));

            sb.Append(ok);

            message = sb.ToString();
        }

        /// <summary>
        /// 返回该对象的字符串表示形式
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 自助借还设备状态报告消息[99]
    /// </summary>
    public class ScStatus : MessageBase
    {
        private char statusCode;

        /// <summary>
        /// 状态代码
        /// </summary>
        public char StatusCode
        {
            get { return statusCode; }
            set { statusCode = value; }
        }
        private char[] maxPrintWidth = new char[3];

        /// <summary>
        /// 最大打印宽度
        /// </summary>
        public char[] MaxPrintWidth
        {
            get { return maxPrintWidth; }
            set { maxPrintWidth = value; }
        }
        private char[] protocolVersion = new char[4];

        /// <summary>
        /// 协议版本
        /// </summary>
        public char[] ProtocolVersion
        {
            get { return protocolVersion; }
            set { protocolVersion = value; }
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="_message"></param>
        public ScStatus(string _message)
        {
            base.Parse(_message);

            //解析数据
            statusCode = message[2];
            maxPrintWidth = message.ToCharArray(3, 3);
            ProtocolVersion = message.ToCharArray(6, 4);
        }

        private void Build()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.ScStatus));

            sb.Append(statusCode);
            sb.Append(maxPrintWidth);
            sb.Append(protocolVersion);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 查询读者状态请求消息[23]
    /// </summary>
    public class PatronStatusRequest : MessageBase
    {
        private char[] language = new char[3];

        public char[] Language
        {
            get { return language; }
            set { language = value; }
        }

        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string patronIdentifier;

        public string PatronIdentifier
        {
            get { return patronIdentifier; }
            set { patronIdentifier = value; }
        }

        private string terminalPassword;

        public string TerminalPassword
        {
            get { return terminalPassword; }
            set { terminalPassword = value; }
        }

        private string patronPassword;

        public string PatronPassword
        {
            get { return patronPassword; }
            set { patronPassword = value; }
        }

        public PatronStatusRequest() { }

        public PatronStatusRequest(string _message)
        {
            base.Parse(_message);

            language = message.ToCharArray(2, 3);
            transactionDate = message.ToCharArray(5, 18);
            institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);
            patronIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], false);
            terminalPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], false);
            patronPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_password.ToString()], false);
        }

        private void Build()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.PatronEnable));

            sb.Append(language);
            sb.Append(transactionDate);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], patronIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], terminalPassword);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_password.ToString()], patronPassword);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 查询读者状态回复消息[24]
    /// </summary>
    public class PatronStatusResponse : MessageBase
    {
        private char[] patronStatus = new char[14];

        /// <summary>
        /// 读者状态
        /// </summary>
        public char[] PatronStatus
        {
            get { return patronStatus; }
            set { patronStatus = value; }
        }

        private char[] language = new char[3];

        /// <summary>
        /// 语言
        /// </summary>
        public char[] Language
        {
            get { return language; }
            set { language = value; }
        }

        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string patronIdentifier;

        public string PatronIdentifier
        {
            get { return patronIdentifier; }
            set { patronIdentifier = value; }
        }

        private string personalName;

        public string PersonalName
        {
            get { return personalName; }
            set { personalName = value; }
        }

        private char validPatron;

        public char ValidPatron
        {
            get { return validPatron; }
            set { validPatron = value; }
        }

        private char validPatronPassword;

        public char ValidPatronPassword
        {
            get { return validPatronPassword; }
            set { validPatronPassword = value; }
        }

        private char[] currencyType = new char[3];

        public char[] CurrencyType
        {
            get { return currencyType; }
            set { currencyType = value; }
        }

        private string feeAmount;

        /// <summary>
        /// 押金总额
        /// </summary>
        public string FeeAmount
        {
            get { return feeAmount; }
            set { feeAmount = value; }
        }

        private string screenMessage;

        public string ScreenMessage
        {
            get { return screenMessage; }
            set { screenMessage = value; }
        }

        private List<string> printLine = new List<string>() { };

        public List<string> PrintLine
        {
            get { return printLine; }
            set { printLine = value; }
        }

        public PatronStatusResponse() { }

        public PatronStatusResponse(string _message)
        {
            base.Parse(_message);

            patronStatus = message.ToCharArray(2, 14);
            language = message.ToCharArray(16, 3);
            transactionDate = message.ToCharArray(19, 18);
            institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);
            patronIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], false);
            personalName = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.personal_name.ToString()], false);

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.valid_patron.ToString()]))
                validPatron = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.valid_patron.ToString()], false)[0];

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.valid_patron_password.ToString()]))
                validPatronPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.valid_patron_password.ToString()], false)[0];

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.currency_type.ToString()]))
                currencyType = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.currency_type.ToString()], false).ToCharArray();

            feeAmount = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.fee_amount.ToString()], false);
            screenMessage = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], false);
            printLine = base.ParseFieldValueList(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()]);
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.PatronEnableResponse));

            sb.Append(patronStatus);
            sb.Append(language);
            sb.Append(transactionDate);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], patronIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.personal_name.ToString()], personalName);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.valid_patron.ToString()], validPatron);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.valid_patron_password.ToString()], validPatronPassword);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.currency_type.ToString()], currencyType);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.fee_amount.ToString()], feeAmount);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], screenMessage);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()], printLine);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 借出图书请求消息[11]
    /// </summary>
    public class Checkout : MessageBase
    {
        private char sCRenewalPolicy;

        public char SCRenewalPolicy
        {
            get { return sCRenewalPolicy; }
            set { sCRenewalPolicy = value; }
        }

        private char noBlock;

        public char NoBlock
        {
            get { return noBlock; }
            set { noBlock = value; }
        }

        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private char[] nbDueDate = new char[18];

        public char[] NbDueDate
        {
            get { return nbDueDate; }
            set { nbDueDate = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string patronIdentifier;

        public string PatronIdentifier
        {
            get { return patronIdentifier; }
            set { patronIdentifier = value; }
        }

        private string terminalPassword;

        public string TerminalPassword
        {
            get { return terminalPassword; }
            set { terminalPassword = value; }
        }

        private string patronPassword;

        public string PatronPassword
        {
            get { return patronPassword; }
            set { patronPassword = value; }
        }

        private string itemProperties;

        public string ItemProperties
        {
            get { return itemProperties; }
            set { itemProperties = value; }
        }

        private string itemIdentifier;

        public string ItemIdentifier
        {
            get { return itemIdentifier; }
            set { itemIdentifier = value; }
        }

        private char feeAcknowledged;

        public char FeeAcknowledged
        {
            get { return feeAcknowledged; }
            set { feeAcknowledged = value; }
        }

        private char cancel;

        public char Cancel
        {
            get { return cancel; }
            set { cancel = value; }
        }

        public Checkout() { }

        public Checkout(string _message)
        {
            base.Parse(_message);

            sCRenewalPolicy = message[2];
            noBlock = message[3];
            transactionDate = message.ToCharArray(4, 18);
            nbDueDate = message.ToCharArray(22, 18);

            institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);
            patronIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], false);
            terminalPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], false);
            patronPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_password.ToString()], false);
            itemIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], false);
            itemProperties = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.item_properties.ToString()], false);

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.fee_acknowledged.ToString()]))
                feeAcknowledged = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.fee_acknowledged.ToString()], false)[0];
            else
                feeAcknowledged = '\0';

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.cancel.ToString()]))
                cancel = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.cancel.ToString()], false)[0];
            else
                cancel = '\0';

        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.Checkout));

            sb.Append(sCRenewalPolicy);
            sb.Append(noBlock);
            sb.Append(transactionDate);
            sb.Append(nbDueDate);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], patronIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], itemIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], terminalPassword);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.item_properties.ToString()], itemProperties);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.patron_password.ToString()], patronPassword);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.fee_acknowledged.ToString()], feeAcknowledged);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.cancel.ToString()], cancel);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 借出图书响应消息[12]
    /// </summary>
    public class CheckoutResponse : MessageBase
    {
        private char ok;

        public char Ok
        {
            get { return ok; }
            set { ok = value; }
        }

        private char renewalOk;

        public char RenewalOk
        {
            get { return renewalOk; }
            set { renewalOk = value; }
        }

        private char magneticMedia;

        /// <summary>
        /// 是否用磁条
        /// </summary>
        public char MagneticMedia
        {
            get { return magneticMedia; }
            set { magneticMedia = value; }
        }

        private char desensitize;

        /// <summary>
        /// 是否需要消磁
        /// </summary>
        public char Desensitize
        {
            get { return desensitize; }
            set { desensitize = value; }
        }

        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string patronIdentifier;

        public string PatronIdentifier
        {
            get { return patronIdentifier; }
            set { patronIdentifier = value; }
        }

        private string itemIdentifier;

        public string ItemIdentifier
        {
            get { return itemIdentifier; }
            set { itemIdentifier = value; }
        }

        private string titleIdentifier;

        public string TitleIdentifier
        {
            get { return titleIdentifier; }
            set { titleIdentifier = value; }
        }

        private string dueDate;

        public string DueDate
        {
            get { return dueDate; }
            set { dueDate = value; }
        }

        private char[] feeType = new char[2];

        public char[] FeeType
        {
            get { return feeType; }
            set { feeType = value; }
        }

        private char securityInhibit;

        public char SecurityInhibit
        {
            get { return securityInhibit; }
            set { securityInhibit = value; }
        }

        private char[] currencyType = new char[3];

        public char[] CurrencyType
        {
            get { return currencyType; }
            set { currencyType = value; }
        }

        private string feeAmount;

        public string FeeAmount
        {
            get { return feeAmount; }
            set { feeAmount = value; }
        }

        private char[] mediaType = new char[3];

        public char[] MediaType
        {
            get { return mediaType; }
            set { mediaType = value; }
        }

        private string itemProperties;

        public string ItemProperties
        {
            get { return itemProperties; }
            set { itemProperties = value; }
        }

        private string transactionId;

        public string TransactionId
        {
            get { return transactionId; }
            set { transactionId = value; }
        }

        private string screenMessage;

        public string ScreenMessage
        {
            get { return screenMessage; }
            set { screenMessage = value; }
        }

        private List<string> printLine = new List<string>() { };

        public List<string> PrintLine
        {
            get { return printLine; }
            set { printLine = value; }
        }

        public CheckoutResponse() { }

        public CheckoutResponse(string _message)
        {
            base.Parse(_message);

            ok = message[2];
            renewalOk = message[3];
            magneticMedia = message[4];
            desensitize = message[5];
            transactionDate = message.ToCharArray(6, 18);

            institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);
            patronIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], false);
            itemIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], false);
            titleIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.title_identifier.ToString()], false);
            dueDate = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.due_date.ToString()], false);

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.fee_type.ToString()]))
                feeType = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.fee_type.ToString()], false).ToCharArray();

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.security_inhibit.ToString()]))
                securityInhibit = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.security_inhibit.ToString()], false)[0];

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.currency_type.ToString()]))
                currencyType = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.currency_type.ToString()], false).ToCharArray();

            feeAmount = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.fee_amount.ToString()], false);

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.media_type.ToString()]))
                mediaType = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.media_type.ToString()], false).ToCharArray();

            itemProperties = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.item_properties.ToString()], false);
            transactionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.transaction_id.ToString()], false);
            screenMessage = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], false);
            printLine = base.ParseFieldValueList(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()]);
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.CheckoutResponse));

            sb.Append(ok);
            sb.Append(renewalOk);
            sb.Append(magneticMedia);
            sb.Append(desensitize);
            sb.Append(transactionDate);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], patronIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], itemIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.title_identifier.ToString()], titleIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.due_date.ToString()], dueDate);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.fee_type.ToString()], feeType);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.security_inhibit.ToString()], securityInhibit);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.currency_type.ToString()], currencyType);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.fee_amount.ToString()], feeAmount);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.media_type.ToString()], mediaType);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.item_properties.ToString()], itemProperties);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.transaction_id.ToString()], transactionId);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], screenMessage);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()], printLine);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 归还图书请求消息[09]
    /// </summary>
    public class Checkin : MessageBase
    {
        private char noBlock;

        public char NoBlock
        {
            get { return noBlock; }
            set { noBlock = value; }
        }

        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private char[] returnDate = new char[18];

        public char[] ReturnDate
        {
            get { return returnDate; }
            set { returnDate = value; }
        }

        private string currentLocation;

        public string CurrentLocation
        {
            get { return currentLocation; }
            set { currentLocation = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string itemIdentifier;

        public string ItemIdentifier
        {
            get { return itemIdentifier; }
            set { itemIdentifier = value; }
        }

        private string terminalPassword;

        public string TerminalPassword
        {
            get { return terminalPassword; }
            set { terminalPassword = value; }
        }

        private string itemProperties;

        public string ItemProperties
        {
            get { return itemProperties; }
            set { itemProperties = value; }
        }

        private char cancel;

        public char Cancel
        {
            get { return cancel; }
            set { cancel = value; }
        }

        public Checkin() { }

        public Checkin(string _message)
        {
            base.Parse(_message);

            noBlock = message[2];
            transactionDate = message.ToCharArray(3, 18);
            returnDate = message.ToCharArray(21, 18);

            currentLocation = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.current_location.ToString()], true);
            institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], false);
            itemIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], false);
            terminalPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], false);
            itemProperties = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.item_properties.ToString()], false);

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.cancel.ToString()]))
                cancel = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.cancel.ToString()], false)[0];
            else
                cancel = '\0';
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.Checkin));

            sb.Append(noBlock);
            sb.Append(transactionDate);
            sb.Append(returnDate);

            Append(Sip2Parameter.dicFieldId[enumFieldName.current_location.ToString()], currentLocation);
            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], itemIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], terminalPassword);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.item_properties.ToString()], itemProperties);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.cancel.ToString()], cancel);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 归还图书响应消息[10]
    /// </summary>
    public class CheckinResponse : MessageBase
    {
        private char ok;

        public char Ok
        {
            get { return ok; }
            set { ok = value; }
        }

        private char resensitize;

        /// <summary>
        /// 是否充磁
        /// </summary>
        public char Resensitize
        {
            get { return resensitize; }
            set { resensitize = value; }
        }

        private char magneticMedia;

        /// <summary>
        /// 是否有磁条
        /// </summary>
        public char MagneticMedia
        {
            get { return magneticMedia; }
            set { magneticMedia = value; }
        }

        private char alert;

        /// <summary>
        /// 是否发出警示音
        /// </summary>
        public char Alert
        {
            get { return alert; }
            set { alert = value; }
        }

        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string itemIdentifier;

        public string ItemIdentifier
        {
            get { return itemIdentifier; }
            set { itemIdentifier = value; }
        }

        private string permanentLocation;

        public string PermanentLocation
        {
            get { return permanentLocation; }
            set { permanentLocation = value; }
        }

        private string titleIdentifier;

        public string TitleIdentifier
        {
            get { return titleIdentifier; }
            set { titleIdentifier = value; }
        }

        private string sortBin;

        public string SortBin
        {
            get { return sortBin; }
            set { sortBin = value; }
        }

        private string patronIdentifier;

        public string PatronIdentifier
        {
            get { return patronIdentifier; }
            set { patronIdentifier = value; }
        }

        private char[] mediaType = new char[3];

        public char[] MediaType
        {
            get { return mediaType; }
            set { mediaType = value; }
        }

        private string itemProperties;

        public string ItemProperties
        {
            get { return itemProperties; }
            set { itemProperties = value; }
        }

        private string screenMessage;

        public string ScreenMessage
        {
            get { return screenMessage; }
            set { screenMessage = value; }
        }

        private List<string> printLine = new List<string>() { };

        public List<string> PrintLine
        {
            get { return printLine; }
            set { printLine = value; }
        }

        public CheckinResponse() { }

        public CheckinResponse(string _message)
        {
            base.Parse(_message);

            ok = message[2];
            resensitize = message[3];
            magneticMedia = message[4];
            alert = message[5];
            transactionDate = message.ToCharArray(6, 18);

            institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);
            itemIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], false);
            permanentLocation = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.permanent_location.ToString()], false);
            titleIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.title_identifier.ToString()], false);
            sortBin = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.sort_bin.ToString()], false);
            patronIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], false);

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.media_type.ToString()]))
                mediaType = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.media_type.ToString()], false).ToCharArray();

            itemProperties = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.item_properties.ToString()], false);
            screenMessage = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], false);
            printLine = base.ParseFieldValueList(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()]);
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.CheckinResponse));

            sb.Append(ok);
            sb.Append(resensitize);
            sb.Append(magneticMedia);
            sb.Append(alert);
            sb.Append(transactionDate);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], itemIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.permanent_location.ToString()], permanentLocation);
            Append(Sip2Parameter.dicFieldId[enumFieldName.title_identifier.ToString()], titleIdentifier);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.sort_bin.ToString()], sortBin);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], patronIdentifier);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.media_type.ToString()], mediaType);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.item_properties.ToString()], itemProperties);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], screenMessage);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()], printLine);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 图书馆流通系统状态报告消息[98]
    /// </summary>
    public class AcsStatus : MessageBase
    {
        private char onlineStatus;

        public char OnlineStatus
        {
            get { return onlineStatus; }
            set { onlineStatus = value; }
        }

        private char checkinOk;

        public char CheckinOk
        {
            get { return checkinOk; }
            set { checkinOk = value; }
        }

        private char checkoutOk;

        public char CheckoutOk
        {
            get { return checkoutOk; }
            set { checkoutOk = value; }
        }

        private char acsRenewalPolicy;

        public char AcsRenewalPolicy
        {
            get { return acsRenewalPolicy; }
            set { acsRenewalPolicy = value; }
        }

        private char statusUpdateOk;

        public char StatusUpdateOk
        {
            get { return statusUpdateOk; }
            set { statusUpdateOk = value; }
        }

        private char offlineOk;

        public char OfflineOk
        {
            get { return offlineOk; }
            set { offlineOk = value; }
        }

        private char[] timeoutPeriod = new char[3];

        public char[] TimeoutPeriod
        {
            get { return timeoutPeriod; }
            set { timeoutPeriod = value; }
        }

        private char[] retriesAllowed = new char[3];

        public char[] RetriesAllowed
        {
            get { return retriesAllowed; }
            set { retriesAllowed = value; }
        }

        private char[] datetimeSync = new char[18];

        public char[] DatetimeSync
        {
            get { return datetimeSync; }
            set { datetimeSync = value; }
        }

        private char[] protocolVersion = new char[4];

        public char[] ProtocolVersion
        {
            get { return protocolVersion; }
            set { protocolVersion = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string libraryName;

        public string LibraryName
        {
            get { return libraryName; }
            set { libraryName = value; }
        }

        private string supportedMessages;

        public string SupportedMessages
        {
            get { return supportedMessages; }
            set { supportedMessages = value; }
        }

        private string terminalLocation;

        public string TerminalLocation
        {
            get { return terminalLocation; }
            set { terminalLocation = value; }
        }

        private string screenMessage;

        public string ScreenMessage
        {
            get { return screenMessage; }
            set { screenMessage = value; }
        }

        private List<string> printLine = new List<string>() { };

        public List<string> PrintLine
        {
            get { return printLine; }
            set { printLine = value; }
        }

        public AcsStatus() { }

        public AcsStatus(string _message)
        {
            base.Parse(message);

            onlineStatus = message[2];
            checkinOk = message[3];
            checkinOk = message[4];
            acsRenewalPolicy = message[5];
            statusUpdateOk = message[6];
            offlineOk = message[7];
            timeoutPeriod = message.ToCharArray(8, 3);
            retriesAllowed = message.ToCharArray(11, 3);
            datetimeSync = message.ToCharArray(14, 18);
            protocolVersion = message.ToCharArray(32, 4);

            institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);
            libraryName = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.library_name.ToString()], true);
            supportedMessages = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.supported_messages.ToString()], true);
            terminalLocation = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.terminal_location.ToString()], true);
            screenMessage = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], true);
            printLine = base.ParseFieldValueList(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()]);
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.AcsStatus));

            sb.Append(onlineStatus);
            sb.Append(checkinOk);
            sb.Append(checkoutOk);
            sb.Append(acsRenewalPolicy);
            sb.Append(statusUpdateOk);
            sb.Append(offlineOk);
            sb.Append(timeoutPeriod);
            sb.Append(retriesAllowed);
            sb.Append(datetimeSync);
            sb.Append(protocolVersion);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.library_name.ToString()], libraryName);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.supported_messages.ToString()], supportedMessages);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.terminal_location.ToString()], terminalLocation);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], supportedMessages);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()], printLine);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 停用读者借书证请求消息[01]
    /// </summary>
    public class BlockPatron : MessageBase
    {
        private char cardRetained;

        public char CardRetained
        {
            get { return cardRetained; }
            set { cardRetained = value; }
        }

        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string blockedCardMsg;

        public string BlockedCardMsg
        {
            get { return blockedCardMsg; }
            set { blockedCardMsg = value; }
        }

        private string patronIdentifier;

        public string PatronIdentifier
        {
            get { return patronIdentifier; }
            set { patronIdentifier = value; }
        }

        private string terminalPassword;

        public string TerminalPassword
        {
            get { return terminalPassword; }
            set { terminalPassword = value; }
        }

        public BlockPatron() { }

        public BlockPatron(string _message)
        {
            base.Parse(_message);

            cardRetained = message[2];
            transactionDate = message.ToCharArray(3, 18);

            institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);
            blockedCardMsg = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.blocked_card_msg.ToString()], false);
            patronIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], false);
            terminalPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], false);
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.BlockPatron));

            sb.Append(cardRetained);
            sb.Append(transactionDate);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], blockedCardMsg);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], patronIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], terminalPassword);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 查询读者信息请求消息[63]
    /// </summary>
    public class PatronInformation : MessageBase
    {
        private char[] language = new char[3];

        public char[] Language
        {
            get { return language; }
            set { language = value; }
        }

        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private char[] summary = new char[10];

        public char[] Summary
        {
            get { return summary; }
            set { summary = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string patronIdentifier;

        public string PatronIdentifier
        {
            get { return patronIdentifier; }
            set { patronIdentifier = value; }
        }

        private string terminalPassword;

        public string TerminalPassword
        {
            get { return terminalPassword; }
            set { terminalPassword = value; }
        }

        private string patronPassword;

        public string PatronPassword
        {
            get { return patronPassword; }
            set { patronPassword = value; }
        }

        private string startItem;

        public string StartItem
        {
            get { return startItem; }
            set { startItem = value; }
        }

        private string endItem;

        public string EndItem
        {
            get { return endItem; }
            set { endItem = value; }
        }

        public PatronInformation() { }

        public PatronInformation(string _message)
        {
            base.Parse(_message);

            language = message.ToCharArray(2, 3);
            transactionDate = message.ToCharArray(5, 18);
            summary = message.ToCharArray(23, 10);

            institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);
            patronIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], false);
            terminalPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], false);
            patronPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_password.ToString()], false);
            startItem = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.start_item.ToString()], false);
            endItem = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.end_item.ToString()], false);
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.PatronInformation));

            sb.Append(language);
            sb.Append(transactionDate);
            sb.Append(summary);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], patronIdentifier);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], terminalPassword);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.patron_password.ToString()], patronPassword);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.start_item.ToString()], startItem);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.end_item.ToString()], endItem);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 读者信息查询回复消息[64]
    /// </summary>
    public class PatronInformationResponse : MessageBase
    {
        private char[] patronStatus = new char[14];

        /// <summary>
        /// 读者状态
        /// </summary>
        public char[] PatronStatus
        {
            get { return patronStatus; }
            set { patronStatus = value; }
        }

        private char[] language = new char[3];

        public char[] Language
        {
            get { return language; }
            set { language = value; }
        }

        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private char[] holdItemsCount = new char[4];

        /// <summary>
        /// 预约图书数
        /// </summary>
        public char[] HoldItemsCount
        {
            get { return holdItemsCount; }
            set { holdItemsCount = value; }
        }

        private char[] overdueItemsCount = new char[4];

        /// <summary>
        /// 超期图书数
        /// </summary>
        public char[] OverdueItemsCount
        {
            get { return overdueItemsCount; }
            set { overdueItemsCount = value; }
        }

        private char[] chargedItemsCount = new char[4];

        /// <summary>
        /// 在借图书数
        /// </summary>
        public char[] ChargedItemsCount
        {
            get { return chargedItemsCount; }
            set { chargedItemsCount = value; }
        }

        private char[] fineItemsCount = new char[4];

        /// <summary>
        /// 罚款图书数
        /// </summary>
        public char[] FineItemsCount
        {
            get { return fineItemsCount; }
            set { fineItemsCount = value; }
        }

        private char[] recallItemsCount = new char[4];

        /// <summary>
        /// 被催还图书数
        /// </summary>
        public char[] RecallItemsCount
        {
            get { return recallItemsCount; }
            set { recallItemsCount = value; }
        }

        private char[] unavailableHoldsCount = new char[4];

        /// <summary>
        /// 无法获取的预约图书数
        /// </summary>
        public char[] UnavailableHoldsCount
        {
            get { return unavailableHoldsCount; }
            set { unavailableHoldsCount = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string patronIdentifier;

        public string PatronIdentifier
        {
            get { return patronIdentifier; }
            set { patronIdentifier = value; }
        }

        private string personalName;

        public string PersonalName
        {
            get { return personalName; }
            set { personalName = value; }
        }

        private char[] holdItemsLimit = new char[4];

        /// <summary>
        /// 预约图书数上限
        /// </summary>
        public char[] HoldItemsLimit
        {
            get { return holdItemsLimit; }
            set { holdItemsLimit = value; }
        }

        private char[] overdueItemsLimit = new char[4];

        /// <summary>
        /// 超期图书数上限
        /// </summary>
        public char[] OverdueItemsLimit
        {
            get { return overdueItemsLimit; }
            set { overdueItemsLimit = value; }
        }

        private char[] chargedItemsLimit = new char[4];

        /// <summary>
        /// 在借图书数上限
        /// </summary>
        public char[] ChargedItemsLimit
        {
            get { return chargedItemsLimit; }
            set { chargedItemsLimit = value; }
        }

        private char validPatron;

        public char ValidPatron
        {
            get { return validPatron; }
            set { validPatron = value; }
        }

        private char validPatronPassword;

        public char ValidPatronPassword
        {
            get { return validPatronPassword; }
            set { validPatronPassword = value; }
        }

        private char[] currencyType = new char[3];

        public char[] CurrencyType
        {
            get { return currencyType; }
            set { currencyType = value; }
        }

        private string feeAmount;

        /// <summary>
        /// 押金总额
        /// </summary>
        public string FeeAmount
        {
            get { return feeAmount; }
            set { feeAmount = value; }
        }

        private string feeLimit;

        /// <summary>
        /// 欠款上限
        /// </summary>
        public string FeeLimit
        {
            get { return feeLimit; }
            set { feeLimit = value; }
        }

        private List<string> holdItems;

        /// <summary>
        /// 预约图书列表
        /// </summary>
        public List<string> HoldItems
        {
            get { return holdItems; }
            set { holdItems = value; }
        }

        private List<string> overdueItems;

        /// <summary>
        /// 超期图书列表
        /// </summary>
        public List<string> OverdueItems
        {
            get { return overdueItems; }
            set { overdueItems = value; }
        }

        private List<string> chargedItems;

        /// <summary>
        /// 在借图书列表
        /// </summary>
        public List<string> ChargedItems
        {
            get { return chargedItems; }
            set { chargedItems = value; }
        }

        private List<string> fineItems;

        /// <summary>
        /// 罚款图书列表
        /// </summary>
        public List<string> FineItems
        {
            get { return fineItems; }
            set { fineItems = value; }
        }

        private List<string> recallItems;

        /// <summary>
        /// 被催还图书列表
        /// </summary>
        public List<string> RecallItems
        {
            get { return recallItems; }
            set { recallItems = value; }
        }

        private List<string> unavailableHoldItems;

        /// <summary>
        /// 无法获取的预约图书列表
        /// </summary>
        public List<string> UnavailableHoldItems
        {
            get { return unavailableHoldItems; }
            set { unavailableHoldItems = value; }
        }

        private string homeAddress;

        public string HomeAddress
        {
            get { return homeAddress; }
            set { homeAddress = value; }
        }

        private string emailAddress;

        public string EmailAddress
        {
            get { return emailAddress; }
            set { emailAddress = value; }
        }

        private string homePhoneNumber;

        public string HomePhoneNumber
        {
            get { return homePhoneNumber; }
            set { homePhoneNumber = value; }
        }

        private string screenMessage;

        public string ScreenMessage
        {
            get { return screenMessage; }
            set { screenMessage = value; }
        }

        private List<string> printLine = new List<string>() { };

        public List<string> PrintLine
        {
            get { return printLine; }
            set { printLine = value; }
        }

        public PatronInformationResponse() { }

        public PatronInformationResponse(string _message)
        {
            base.Parse(_message);

            patronStatus = message.ToCharArray(2, 14);
            language = message.ToCharArray(16, 3);
            transactionDate = message.ToCharArray(19, 18);
            holdItemsCount = message.ToCharArray(37, 4);
            overdueItemsCount = message.ToCharArray(41, 4);
            chargedItemsCount = message.ToCharArray(41, 4);
            fineItemsCount = message.ToCharArray(41, 4);
            recallItemsCount = message.ToCharArray(41, 4);
            unavailableHoldsCount = message.ToCharArray(41, 4);

            institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);
            patronIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], false);
            personalName = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.personal_name.ToString()], false);

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.hold_items_limit.ToString()]))
                holdItemsLimit = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.hold_items_limit.ToString()], false).ToCharArray();

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.overdue_items_limit.ToString()]))
                overdueItemsLimit = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.overdue_items_limit.ToString()], false).ToCharArray();

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.charged_items_limit.ToString()]))
                chargedItemsLimit = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.charged_items_limit.ToString()], false).ToCharArray();

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.valid_patron.ToString()]))
                validPatron = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.valid_patron.ToString()], false)[0];

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.valid_patron_password.ToString()]))
                validPatronPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.valid_patron_password.ToString()], false)[0];

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.currency_type.ToString()]))
                currencyType = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.currency_type.ToString()], false).ToCharArray();

            feeAmount = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.fee_amount.ToString()], false);
            feeLimit = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.fee_limit.ToString()], false);
            holdItems = base.ParseFieldValueList(Sip2Parameter.dicFieldId[enumFieldName.hold_items.ToString()]);
            overdueItems = base.ParseFieldValueList(Sip2Parameter.dicFieldId[enumFieldName.overdue_items.ToString()]);
            chargedItems = base.ParseFieldValueList(Sip2Parameter.dicFieldId[enumFieldName.charged_items.ToString()]);
            fineItems = base.ParseFieldValueList(Sip2Parameter.dicFieldId[enumFieldName.fine_items.ToString()]);
            recallItems = base.ParseFieldValueList(Sip2Parameter.dicFieldId[enumFieldName.recall_items.ToString()]);
            unavailableHoldItems = base.ParseFieldValueList(Sip2Parameter.dicFieldId[enumFieldName.unavailable_hold_items.ToString()]);
            homeAddress = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.home_address.ToString()], false);
            emailAddress = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.email_address.ToString()], false);
            homePhoneNumber = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.home_phone_number.ToString()], false);

            screenMessage = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], false);
            printLine = base.ParseFieldValueList(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()]);
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.PatronInformationResponse));

            sb.Append(patronStatus);
            sb.Append(language);
            sb.Append(transactionDate);
            sb.Append(holdItemsCount);
            sb.Append(overdueItemsCount);
            sb.Append(chargedItemsCount);
            sb.Append(fineItemsCount);
            sb.Append(recallItemsCount);
            sb.Append(unavailableHoldsCount);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], patronIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.personal_name.ToString()], personalName);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.hold_items_limit.ToString()], holdItemsLimit);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.overdue_items_limit.ToString()], overdueItemsLimit);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.charged_items_limit.ToString()], chargedItemsLimit);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.valid_patron.ToString()], validPatron);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.valid_patron_password.ToString()], validPatronPassword);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.currency_type.ToString()], currencyType);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.fee_amount.ToString()], feeAmount);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.fee_limit.ToString()], feeLimit);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.hold_items.ToString()], holdItems);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.overdue_items.ToString()], overdueItems);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.charged_items.ToString()], chargedItems);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.fine_items.ToString()], fineItems);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.recall_items.ToString()], recallItems);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.unavailable_hold_items.ToString()], unavailableHoldItems);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.home_address.ToString()], homeAddress);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.email_address.ToString()], emailAddress);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.home_phone_number.ToString()], homePhoneNumber);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], screenMessage);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()], printLine);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 结束读者会话请求消息[35]
    /// </summary>
    public class EndPatronSession : MessageBase
    {
        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string patronIdentifier;

        public string PatronIdentifier
        {
            get { return patronIdentifier; }
            set { patronIdentifier = value; }
        }

        private string terminalPassword;

        public string TerminalPassword
        {
            get { return terminalPassword; }
            set { terminalPassword = value; }
        }

        private string patronPassword;

        public string PatronPassword
        {
            get { return patronPassword; }
            set { patronPassword = value; }
        }

        public EndPatronSession() { }

        public EndPatronSession(string _message)
        {
            base.Parse(_message);

            transactionDate = message.ToCharArray(2, 18);

            institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);
            patronIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], false);
            terminalPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], false);
            patronPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_password.ToString()], false);
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.EndPatronSession));

            sb.Append(transactionDate);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], patronIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], terminalPassword);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_password.ToString()], patronPassword);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 结束会话回复消息[36]
    /// </summary>
    public class EndSessionResponse : MessageBase
    {
        private char endSession;

        public char EndSession
        {
            get { return endSession; }
            set { endSession = value; }
        }

        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string patronIdentifier;

        public string PatronIdentifier
        {
            get { return patronIdentifier; }
            set { patronIdentifier = value; }
        }

        private string screenMessage;

        public string ScreenMessage
        {
            get { return screenMessage; }
            set { screenMessage = value; }
        }

        private List<string> printLine = new List<string>() { };

        public List<string> PrintLine
        {
            get { return printLine; }
            set { printLine = value; }
        }

        public EndSessionResponse() { }

        public EndSessionResponse(string _message)
        {
            base.Parse(_message);

            endSession = message[2];
            transactionDate = message.ToCharArray(3, 18);

            institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);
            patronIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], false);

            screenMessage = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], false);
            printLine = base.ParseFieldValueList(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()]);
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.EndSessionResponse));

            sb.Append(endSession);
            sb.Append(transactionDate);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], patronIdentifier);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], screenMessage);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()], printLine);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 缴费请求消息[37]
    /// </summary>
    public class FeePaid : MessageBase
    {
        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private char[] feeType = new char[2];

        public char[] FeeType
        {
            get { return feeType; }
            set { feeType = value; }
        }

        private char[] paymentType = new char[2];

        public char[] PaymentType
        {
            get { return paymentType; }
            set { paymentType = value; }
        }

        private char[] currencyType = new char[3];

        public char[] CurrencyType
        {
            get { return currencyType; }
            set { currencyType = value; }
        }

        private string feeAmount;

        public string FeeAmount
        {
            get { return feeAmount; }
            set { feeAmount = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string patronIdentifier;

        public string PatronIdentifier
        {
            get { return patronIdentifier; }
            set { patronIdentifier = value; }
        }

        private string terminalPassword;

        public string TerminalPassword
        {
            get { return terminalPassword; }
            set { terminalPassword = value; }
        }

        private string patronPassword;

        public string PatronPassword
        {
            get { return patronPassword; }
            set { patronPassword = value; }
        }

        private string feeIdentifier;

        public string FeeIdentifier
        {
            get { return feeIdentifier; }
            set { feeIdentifier = value; }
        }

        private string transactionId;

        public string TransactionId
        {
            get { return transactionId; }
            set { transactionId = value; }
        }

        public FeePaid() { }

        public FeePaid(string _message)
        {
            base.Parse(_message);

            transactionDate = message.ToCharArray(2, 18);
            feeType = message.ToCharArray(20, 2);
            paymentType = message.ToCharArray(22, 2);
            currencyType = message.ToCharArray(24, 3);

            feeAmount = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.fee_amount.ToString()], true);
            institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], false);
            patronIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], false);
            terminalPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], false);
            patronPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_password.ToString()], false);
            feeIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.fee_identifier.ToString()], false);
            transactionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.transaction_id.ToString()], false);

        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.FeePaid));

            sb.Append(transactionDate);
            sb.Append(feeType);
            sb.Append(paymentType);
            sb.Append(currencyType);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], patronIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], terminalPassword);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_password.ToString()], patronPassword);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.fee_identifier.ToString()], feeIdentifier);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.transaction_id.ToString()], transactionId);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 缴费回复消息[38]
    /// </summary>
    public class FeePaidResponse : MessageBase
    {
        private char paymentAccepted;

        public char PaymentAccepted
        {
            get { return paymentAccepted; }
            set { paymentAccepted = value; }
        }

        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string patronIdentifier;

        public string PatronIdentifier
        {
            get { return patronIdentifier; }
            set { patronIdentifier = value; }
        }

        private string transactionId;

        public string TransactionId
        {
            get { return transactionId; }
            set { transactionId = value; }
        }

        private string screenMessage;

        public string ScreenMessage
        {
            get { return screenMessage; }
            set { screenMessage = value; }
        }

        private List<string> printLine = new List<string>() { };

        public List<string> PrintLine
        {
            get { return printLine; }
            set { printLine = value; }
        }

        public FeePaidResponse() { }

        public FeePaidResponse(string _message)
        {
            base.Parse(_message);

            paymentAccepted = message[2];
            transactionDate = message.ToCharArray(3, 18);

            institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);
            patronIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], false);

            transactionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.transaction_id.ToString()], false);
            screenMessage = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], false);
            printLine = base.ParseFieldValueList(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()]);
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.EndSessionResponse));

            sb.Append(paymentAccepted);
            sb.Append(transactionDate);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], patronIdentifier);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.transaction_id.ToString()], transactionId);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], screenMessage);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()], printLine);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 图书信息查询消息[17]
    /// </summary>
    public class ItemInformation : MessageBase
    {
        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string itemIdentifier;

        public string ItemIdentifier
        {
            get { return itemIdentifier; }
            set { itemIdentifier = value; }
        }

        private string terminalPassword;

        public string TerminalPassword
        {
            get { return terminalPassword; }
            set { terminalPassword = value; }
        }

        public ItemInformation() { }

        public ItemInformation(string _message)
        {
            base.Parse(_message);

            transactionDate = message.ToCharArray(2, 18);

            institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);
            itemIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], false);
            terminalPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], false);
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.ItemInformation));

            sb.Append(transactionDate);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], itemIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], terminalPassword);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 图书信息查询回复消息[18]
    /// </summary>
    public class ItemInformationResponse : MessageBase
    {
        private char[] circulationStatus = new char[2];

        public char[] CirculationStatus
        {
            get { return circulationStatus; }
            set { circulationStatus = value; }
        }

        private char[] securityMarker = new char[2];

        public char[] SecurityMarker
        {
            get { return securityMarker; }
            set { securityMarker = value; }
        }

        private char[] feeType = new char[2];

        public char[] FeeType
        {
            get { return feeType; }
            set { feeType = value; }
        }

        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private string holdQueueLength;

        public string HoldQueueLength
        {
            get { return holdQueueLength; }
            set { holdQueueLength = value; }
        }

        private string dueDate;

        public string DueDate
        {
            get { return dueDate; }
            set { dueDate = value; }
        }

        private char[] recallDate = new char[18];

        public char[] RecallDate
        {
            get { return recallDate; }
            set { recallDate = value; }
        }

        private char[] holdPickupDate = new char[18];

        public char[] HoldPickupDate
        {
            get { return holdPickupDate; }
            set { holdPickupDate = value; }
        }

        private string itemIdentifier;

        public string ItemIdentifier
        {
            get { return itemIdentifier; }
            set { itemIdentifier = value; }
        }

        private string titleIdentifier;

        public string TitleIdentifier
        {
            get { return titleIdentifier; }
            set { titleIdentifier = value; }
        }

        private string owner;

        public string Owner
        {
            get { return owner; }
            set { owner = value; }
        }

        private char[] currencyType = new char[3];

        public char[] CurrencyType
        {
            get { return currencyType; }
            set { currencyType = value; }
        }

        private string feeAmount;

        public string FeeAmount
        {
            get { return feeAmount; }
            set { feeAmount = value; }
        }

        private char[] mediaType = new char[3];

        public char[] MediaType
        {
            get { return mediaType; }
            set { mediaType = value; }
        }

        private string permanentLocation;

        public string PermanentLocation
        {
            get { return permanentLocation; }
            set { permanentLocation = value; }
        }

        private string currentLocation;

        public string CurrentLocation
        {
            get { return currentLocation; }
            set { currentLocation = value; }
        }

        private string itemProperties;

        public string ItemProperties
        {
            get { return itemProperties; }
            set { itemProperties = value; }
        }

        private string screenMessage;

        public string ScreenMessage
        {
            get { return screenMessage; }
            set { screenMessage = value; }
        }

        private List<string> printLine = new List<string>() { };

        public List<string> PrintLine
        {
            get { return printLine; }
            set { printLine = value; }
        }

        public ItemInformationResponse() { }

        public ItemInformationResponse(string _message)
        {
            base.Parse(_message);

            circulationStatus = message.ToCharArray(2, 2);
            securityMarker = message.ToCharArray(4, 2);
            feeType = message.ToCharArray(6, 2);
            transactionDate = message.ToCharArray(8, 18);

            holdQueueLength = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.hold_queue_length.ToString()], true);
            dueDate = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.due_date.ToString()], true);

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.recall_date.ToString()]))
                recallDate = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.recall_date.ToString()], true).ToCharArray();

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.hold_pickup_date.ToString()]))
                holdPickupDate = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.hold_pickup_date.ToString()], true).ToCharArray();

            itemIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], false);
            titleIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.title_identifier.ToString()], false);
            owner = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.owner.ToString()], false);

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.currency_type.ToString()]))
                currencyType = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.currency_type.ToString()], false).ToCharArray();

            feeAmount = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.fee_amount.ToString()], false);

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.media_type.ToString()]))
                mediaType = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.media_type.ToString()], false).ToCharArray();

            permanentLocation = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.permanent_location.ToString()], false);
            currentLocation = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.current_location.ToString()], false);
            itemProperties = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.item_properties.ToString()], false);
            screenMessage = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], false);
            printLine = base.ParseFieldValueList(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()]);
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.ItemInformationResponse));

            sb.Append(circulationStatus);
            sb.Append(securityMarker);
            sb.Append(feeType);
            sb.Append(transactionDate);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.hold_queue_length.ToString()], holdQueueLength);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.due_date.ToString()], dueDate);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.recall_date.ToString()], recallDate);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.hold_pickup_date.ToString()], holdPickupDate);

            Append(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], itemIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.title_identifier.ToString()], titleIdentifier);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.owner.ToString()], owner);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.currency_type.ToString()], currencyType);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.fee_amount.ToString()], feeAmount);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.media_type.ToString()], mediaType);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.permanent_location.ToString()], permanentLocation);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.current_location.ToString()], currentLocation);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.item_properties.ToString()], itemProperties);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], screenMessage);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()], printLine);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 请求修改图书状态消息[19]
    /// </summary>
    public class ItemStatusUpdate : MessageBase
    {
        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string itemIdentifier;

        public string ItemIdentifier
        {
            get { return itemIdentifier; }
            set { itemIdentifier = value; }
        }

        private string terminalPassword;

        public string TerminalPassword
        {
            get { return terminalPassword; }
            set { terminalPassword = value; }
        }

        private string itemProperties;

        public string ItemProperties
        {
            get { return itemProperties; }
            set { itemProperties = value; }
        }

        public ItemStatusUpdate() { }

        public ItemStatusUpdate(string _message)
        {
            base.Parse(_message);

            transactionDate = message.ToCharArray(2, 18);

            institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);
            itemIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], false);
            terminalPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], false);
            itemProperties = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.item_properties.ToString()], false);
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.ItemStatusUpdate));

            sb.Append(transactionDate);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], itemIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], terminalPassword);
            Append(Sip2Parameter.dicFieldId[enumFieldName.item_properties.ToString()], itemProperties);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 修改图书状态回复消息[20]
    /// </summary>
    public class ItemStatusUpdateResponse : MessageBase
    {
        private char itemPropertiesOk;

        public char ItemPropertiesOk
        {
            get { return itemPropertiesOk; }
            set { itemPropertiesOk = value; }
        }

        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private string itemIdentifier;

        public string ItemIdentifier
        {
            get { return itemIdentifier; }
            set { itemIdentifier = value; }
        }

        private string titleIdentifier;

        public string TitleIdentifier
        {
            get { return titleIdentifier; }
            set { titleIdentifier = value; }
        }

        private string itemProperties;

        public string ItemProperties
        {
            get { return itemProperties; }
            set { itemProperties = value; }
        }

        private string screenMessage;

        public string ScreenMessage
        {
            get { return screenMessage; }
            set { screenMessage = value; }
        }

        private List<string> printLine = new List<string>() { };

        public List<string> PrintLine
        {
            get { return printLine; }
            set { printLine = value; }
        }

        public ItemStatusUpdateResponse() { }

        public ItemStatusUpdateResponse(string _message)
        {
            base.Parse(_message);

            itemPropertiesOk = message[2];
            transactionDate = message.ToCharArray(3, 18);

            itemIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], true);
            titleIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.title_identifier.ToString()], false);

            itemProperties = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.item_properties.ToString()], false);
            screenMessage = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], false);
            printLine = base.ParseFieldValueList(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()]);
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.ItemStatusUpdateResponse));

            sb.Append(itemPropertiesOk);
            sb.Append(transactionDate);

            Append(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], itemIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.title_identifier.ToString()], titleIdentifier);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.item_properties.ToString()], itemProperties);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], screenMessage);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()], printLine);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 启用读者借书证请求消息[25]
    /// </summary>
    public class PatronEnable : MessageBase
    {
        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string patronIdentifier;

        public string PatronIdentifier
        {
            get { return patronIdentifier; }
            set { patronIdentifier = value; }
        }

        private string terminalPassword;

        public string TerminalPassword
        {
            get { return terminalPassword; }
            set { terminalPassword = value; }
        }

        private string patronPassword;

        public string PatronPassword
        {
            get { return patronPassword; }
            set { patronPassword = value; }
        }

        public PatronEnable() { }

        public PatronEnable(string _message)
        {
            base.Parse(_message);

            transactionDate = message.ToCharArray(2, 18);

            institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);
            patronIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], false);
            terminalPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], false);
            patronPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_password.ToString()], false);
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.PatronEnable));

            sb.Append(transactionDate);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], patronIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], terminalPassword);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_password.ToString()], patronPassword);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 启用读者借书证回复消息[26]
    /// </summary>
    public class PatronEnableResponse : MessageBase
    {
        private char[] patronStatus = new char[14];

        public char[] PatronStatus
        {
            get { return patronStatus; }
            set { patronStatus = value; }
        }

        private char[] language = new char[3];

        public char[] Language
        {
            get { return language; }
            set { language = value; }
        }

        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string patronIdentifier;

        public string PatronIdentifier
        {
            get { return patronIdentifier; }
            set { patronIdentifier = value; }
        }

        private string personalName;

        public string PersonalName
        {
            get { return personalName; }
            set { personalName = value; }
        }

        private char validPatron;

        public char ValidPatron
        {
            get { return validPatron; }
            set { validPatron = value; }
        }

        private char validPatronPassword;

        public char ValidPatronPassword
        {
            get { return validPatronPassword; }
            set { validPatronPassword = value; }
        }

        private string screenMessage;

        public string ScreenMessage
        {
            get { return screenMessage; }
            set { screenMessage = value; }
        }

        private List<string> printLine = new List<string>() { };

        public List<string> PrintLine
        {
            get { return printLine; }
            set { printLine = value; }
        }

        public PatronEnableResponse() { }

        public PatronEnableResponse(string _message)
        {
            base.Parse(_message);

            patronStatus = message.ToCharArray(2, 14);
            language = message.ToCharArray(16, 3);
            transactionDate = message.ToCharArray(19, 18);

            institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);
            patronIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], false);
            personalName = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.personal_name.ToString()], false);

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.valid_patron.ToString()]))
                validPatron = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.valid_patron.ToString()], false)[0];

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.valid_patron_password.ToString()]))
                validPatronPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.valid_patron_password.ToString()], false)[0];

            screenMessage = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], false);
            printLine = base.ParseFieldValueList(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()]);
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.PatronEnableResponse));

            sb.Append(patronStatus);
            sb.Append(language);
            sb.Append(transactionDate);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], patronIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.personal_name.ToString()], personalName);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.valid_patron.ToString()], validPatron);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.valid_patron_password.ToString()], validPatronPassword);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], screenMessage);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()], printLine);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 保留图书请求消息[15]
    /// </summary>
    public class Hold : MessageBase
    {
        private char holdMode;

        public char HoldMode
        {
            get { return holdMode; }
            set { holdMode = value; }
        }

        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private char[] expirationDate = new char[18];

        public char[] ExpirationDate
        {
            get { return expirationDate; }
            set { expirationDate = value; }
        }

        private string pickupLocation;

        public string PickupLocation
        {
            get { return pickupLocation; }
            set { pickupLocation = value; }
        }

        private char holdType;

        public char HoldType
        {
            get { return holdType; }
            set { holdType = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string patronIdentifier;

        public string PatronIdentifier
        {
            get { return patronIdentifier; }
            set { patronIdentifier = value; }
        }

        private string patronPassword;

        public string PatronPassword
        {
            get { return patronPassword; }
            set { patronPassword = value; }
        }

        private string itemIdentifier;

        public string ItemIdentifier
        {
            get { return itemIdentifier; }
            set { itemIdentifier = value; }
        }

        private string titleIdentifier;

        public string TitleIdentifier
        {
            get { return titleIdentifier; }
            set { titleIdentifier = value; }
        }

        private string terminalPassword;

        public string TerminalPassword
        {
            get { return terminalPassword; }
            set { terminalPassword = value; }
        }

        private char feeAcknowledged;

        public char FeeAcknowledged
        {
            get { return feeAcknowledged; }
            set { feeAcknowledged = value; }
        }

        public Hold() { }

        public Hold(string _message)
        {
            base.Parse(_message);

            holdMode = message[2];
            transactionDate = message.ToCharArray(3, 18);

            string _expirationDate = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.expiration_date.ToString()], true);

            if (!string.IsNullOrEmpty(_expirationDate))
                expirationDate = _expirationDate.ToCharArray();

            if (string.IsNullOrEmpty(_expirationDate))
                pickupLocation = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.pickup_location.ToString()], true);
            else
                pickupLocation = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.pickup_location.ToString()], false);

            string _holdType;

            if (string.IsNullOrEmpty(_expirationDate) && string.IsNullOrEmpty(pickupLocation))
                _holdType = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.hold_type.ToString()], true);
            else
                _holdType = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.hold_type.ToString()], false);

            holdType = string.IsNullOrEmpty(_holdType) ? ' ' : _holdType[0];

            if (string.IsNullOrEmpty(_expirationDate) && string.IsNullOrEmpty(pickupLocation) && string.IsNullOrEmpty(_holdType))
                institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);
            else
                institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], false);

            patronIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], false);
            patronPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_password.ToString()], false);
            itemIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], false);
            titleIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.title_identifier.ToString()], false);
            terminalPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], false);

            string _feeAcknowledged = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.fee_acknowledged.ToString()], false);

            feeAcknowledged = string.IsNullOrEmpty(_feeAcknowledged) ? ' ' : _feeAcknowledged[0];
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.Hold));

            sb.Append(holdMode);
            sb.Append(transactionDate);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.expiration_date.ToString()], expirationDate);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.hold_type.ToString()], holdType);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], patronIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], itemIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.title_identifier.ToString()], titleIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], terminalPassword);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.fee_acknowledged.ToString()], feeAcknowledged);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 预约图书回复消息[16]
    /// </summary>
    public class HoldResponse : MessageBase
    {
        private char ok;

        public char Ok
        {
            get { return ok; }
            set { ok = value; }
        }

        private char available;

        public char Available
        {
            get { return available; }
            set { available = value; }
        }

        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private char[] expirationDate = new char[18];

        public char[] ExpirationDate
        {
            get { return expirationDate; }
            set { expirationDate = value; }
        }

        private string queuePosition;

        public string QueuePosition
        {
            get { return queuePosition; }
            set { queuePosition = value; }
        }

        private string pickupLocation;

        public string PickupLocation
        {
            get { return pickupLocation; }
            set { pickupLocation = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string patronIdentifier;

        public string PatronIdentifier
        {
            get { return patronIdentifier; }
            set { patronIdentifier = value; }
        }

        private string itemIdentifier;

        public string ItemIdentifier
        {
            get { return itemIdentifier; }
            set { itemIdentifier = value; }
        }

        private string titleIdentifier;

        public string TitleIdentifier
        {
            get { return titleIdentifier; }
            set { titleIdentifier = value; }
        }

        private string screenMessage;

        public string ScreenMessage
        {
            get { return screenMessage; }
            set { screenMessage = value; }
        }

        private List<string> printLine = new List<string>() { };

        public List<string> PrintLine
        {
            get { return printLine; }
            set { printLine = value; }
        }

        public HoldResponse() { }

        public HoldResponse(string _message)
        {
            base.Parse(_message);

            ok = message[2];
            available = message[3];
            transactionDate = message.ToCharArray(4, 18);

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.expiration_date.ToString()]))
                expirationDate = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], true).ToCharArray();

            if (expirationDate[0] == '\0')
                queuePosition = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.queue_position.ToString()], true);
            else
                queuePosition = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.queue_position.ToString()], false);

            if (expirationDate[0] == '\0' && string.IsNullOrEmpty(queuePosition))
                pickupLocation = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.pickup_location.ToString()], true);
            else
                pickupLocation = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.pickup_location.ToString()], false);

            if (expirationDate[0] == '\0' && string.IsNullOrEmpty(queuePosition) && string.IsNullOrEmpty(pickupLocation))
                institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);
            else
                institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);

            patronIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], false);

            itemIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], false);
            titleIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.title_identifier.ToString()], false);
            screenMessage = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], false);
            printLine = base.ParseFieldValueList(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()]);
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.ItemStatusUpdateResponse));

            sb.Append(ok);
            sb.Append(available);
            sb.Append(transactionDate);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.expiration_date.ToString()], expirationDate);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.queue_position.ToString()], queuePosition);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.pickup_location.ToString()], pickupLocation);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], patronIdentifier);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], itemIdentifier);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.title_identifier.ToString()], titleIdentifier);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], screenMessage);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()], printLine);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 单本续借请求消息[29]
    /// </summary>
    public class Renew : MessageBase
    {
        private char thirdPartyAllowed;

        public char ThirdPartyAllowed
        {
            get { return thirdPartyAllowed; }
            set { thirdPartyAllowed = value; }
        }

        private char noBlock;

        public char NoBlock
        {
            get { return noBlock; }
            set { noBlock = value; }
        }

        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private char[] nbDueDate = new char[18];

        public char[] NbDueDate
        {
            get { return nbDueDate; }
            set { nbDueDate = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string patronIdentifier;

        public string PatronIdentifier
        {
            get { return patronIdentifier; }
            set { patronIdentifier = value; }
        }

        private string patronPassword;

        public string PatronPassword
        {
            get { return patronPassword; }
            set { patronPassword = value; }
        }

        private string itemIdentifier;

        public string ItemIdentifier
        {
            get { return itemIdentifier; }
            set { itemIdentifier = value; }
        }

        private string titleIdentifier;

        public string TitleIdentifier
        {
            get { return titleIdentifier; }
            set { titleIdentifier = value; }
        }

        private string terminalPassword;

        public string TerminalPassword
        {
            get { return terminalPassword; }
            set { terminalPassword = value; }
        }

        private string itemProperties;

        public string ItemProperties
        {
            get { return itemProperties; }
            set { itemProperties = value; }
        }

        private char feeAcknowledged;

        public char FeeAcknowledged
        {
            get { return feeAcknowledged; }
            set { feeAcknowledged = value; }
        }

        public Renew() { }

        public Renew(string _message)
        {
            base.Parse(_message);

            thirdPartyAllowed = message[2];
            noBlock = message[3];
            transactionDate = message.ToCharArray(4, 18);
            nbDueDate = message.ToCharArray(22, 18);

            institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);
            patronIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], false);
            patronPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_password.ToString()], false);
            itemIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], false);
            titleIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.title_identifier.ToString()], false);
            terminalPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], false);
            itemProperties = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.item_properties.ToString()], false);

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.fee_acknowledged.ToString()]))
                feeAcknowledged = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.fee_acknowledged.ToString()], false)[0];
            else
                feeAcknowledged = '\0';
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.Renew));

            sb.Append(thirdPartyAllowed);
            sb.Append(noBlock);
            sb.Append(transactionDate);
            sb.Append(nbDueDate);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], patronIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_password.ToString()], patronPassword);
            Append(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], itemIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.title_identifier.ToString()], titleIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], terminalPassword);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.item_properties.ToString()], itemProperties);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.fee_acknowledged.ToString()], feeAcknowledged);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 借出图书响应消息[12]
    /// </summary>
    public class RenewResponse : MessageBase
    {
        private char ok;

        public char Ok
        {
            get { return ok; }
            set { ok = value; }
        }

        private char renewalOk;

        public char RenewalOk
        {
            get { return renewalOk; }
            set { renewalOk = value; }
        }

        private char magneticMedia;

        public char MagneticMedia
        {
            get { return magneticMedia; }
            set { magneticMedia = value; }
        }

        private char desensitize;

        public char Desensitize
        {
            get { return desensitize; }
            set { desensitize = value; }
        }

        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string patronIdentifier;

        public string PatronIdentifier
        {
            get { return patronIdentifier; }
            set { patronIdentifier = value; }
        }

        private string itemIdentifier;

        public string ItemIdentifier
        {
            get { return itemIdentifier; }
            set { itemIdentifier = value; }
        }

        private string titleIdentifier;

        public string TitleIdentifier
        {
            get { return titleIdentifier; }
            set { titleIdentifier = value; }
        }

        private string dueDate;

        public string DueDate
        {
            get { return dueDate; }
            set { dueDate = value; }
        }

        private char[] feeType = new char[2];

        public char[] FeeType
        {
            get { return feeType; }
            set { feeType = value; }
        }

        private char securityInhibit;

        public char SecurityInhibit
        {
            get { return securityInhibit; }
            set { securityInhibit = value; }
        }

        private char[] currencyType = new char[3];

        public char[] CurrencyType
        {
            get { return currencyType; }
            set { currencyType = value; }
        }

        private string feeAmount;

        public string FeeAmount
        {
            get { return feeAmount; }
            set { feeAmount = value; }
        }

        private char[] mediaType = new char[3];

        public char[] MediaType
        {
            get { return mediaType; }
            set { mediaType = value; }
        }

        private string itemProperties;

        public string ItemProperties
        {
            get { return itemProperties; }
            set { itemProperties = value; }
        }

        private string transactionId;

        public string TransactionId
        {
            get { return transactionId; }
            set { transactionId = value; }
        }

        private string screenMessage;

        public string ScreenMessage
        {
            get { return screenMessage; }
            set { screenMessage = value; }
        }

        private List<string> printLine = new List<string>() { };

        public List<string> PrintLine
        {
            get { return printLine; }
            set { printLine = value; }
        }

        public RenewResponse() { }

        /// <summary>
        /// 续借响应消息[30]
        /// </summary>
        /// <param name="_message"></param>
        public RenewResponse(string _message)
        {
            base.Parse(_message);

            ok = message[2];
            renewalOk = message[3];
            magneticMedia = message[4];
            desensitize = message[5];
            transactionDate = message.ToCharArray(6, 18);

            institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);
            patronIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], false);
            itemIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], false);
            titleIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.title_identifier.ToString()], false);
            dueDate = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.due_date.ToString()], false);

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.fee_type.ToString()]))
                feeType = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.fee_type.ToString()], false).ToCharArray();

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.security_inhibit.ToString()]))
                securityInhibit = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.security_inhibit.ToString()], false)[0];

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.currency_type.ToString()]))
                currencyType = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.currency_type.ToString()], false).ToCharArray();

            feeAmount = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.fee_amount.ToString()], false);

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.media_type.ToString()]))
                mediaType = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.media_type.ToString()], false).ToCharArray();

            itemProperties = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.item_properties.ToString()], false);
            transactionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.transaction_id.ToString()], false);
            screenMessage = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], false);
            printLine = base.ParseFieldValueList(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()]);
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.RenewResponse));

            sb.Append(ok);
            sb.Append(renewalOk);
            sb.Append(magneticMedia);
            sb.Append(desensitize);
            sb.Append(transactionDate);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], patronIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.item_identifier.ToString()], itemIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.title_identifier.ToString()], titleIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.due_date.ToString()], dueDate);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.fee_type.ToString()], feeType);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.security_inhibit.ToString()], securityInhibit);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.currency_type.ToString()], currencyType);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.fee_amount.ToString()], feeAmount);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.media_type.ToString()], mediaType);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.item_properties.ToString()], itemProperties);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.transaction_id.ToString()], transactionId);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], screenMessage);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()], printLine);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 全部图书续借请求消息[65]
    /// </summary>
    public class RenewAll : MessageBase
    {
        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private string patronIdentifier;

        public string PatronIdentifier
        {
            get { return patronIdentifier; }
            set { patronIdentifier = value; }
        }

        private string patronPassword;

        public string PatronPassword
        {
            get { return patronPassword; }
            set { patronPassword = value; }
        }

        private string terminalPassword;

        public string TerminalPassword
        {
            get { return terminalPassword; }
            set { terminalPassword = value; }
        }

        private char feeAcknowledged;

        public char FeeAcknowledged
        {
            get { return feeAcknowledged; }
            set { feeAcknowledged = value; }
        }

        public RenewAll(string _message)
        {
            base.Parse(_message);

            transactionDate = message.ToCharArray(2, 18);

            institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);
            patronIdentifier = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], false);
            patronPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.patron_password.ToString()], false);
            terminalPassword = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], false);

            if (base.OptionFieldIsExist(Sip2Parameter.dicFieldId[enumFieldName.fee_acknowledged.ToString()]))
                feeAcknowledged = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.fee_acknowledged.ToString()], false)[0];
            else
                feeAcknowledged = '\0';
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.RenewAll));

            sb.Append(transactionDate);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_identifier.ToString()], patronIdentifier);
            Append(Sip2Parameter.dicFieldId[enumFieldName.patron_password.ToString()], patronPassword);
            Append(Sip2Parameter.dicFieldId[enumFieldName.terminal_password.ToString()], terminalPassword);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.fee_acknowledged.ToString()], feeAcknowledged);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    ///  全部图书续借回复消息[66]
    /// </summary>
    public class RenewAllResponse : MessageBase
    {
        private char ok;

        public char Ok
        {
            get { return ok; }
            set { ok = value; }
        }

        private char[] renewedCount;

        public char[] RenewedCount
        {
            get { return renewedCount; }
            set { renewedCount = value; }
        }

        private char[] unrenewedCount;

        public char[] UnrenewedCount
        {
            get { return unrenewedCount; }
            set { unrenewedCount = value; }
        }

        private char[] transactionDate = new char[18];

        public char[] TransactionDate
        {
            get { return transactionDate; }
            set { transactionDate = value; }
        }

        private string institutionId;

        public string InstitutionId
        {
            get { return institutionId; }
            set { institutionId = value; }
        }

        private List<string> renewedItems;

        public List<string> RenewedItems
        {
            get { return renewedItems; }
            set { renewedItems = value; }
        }

        private List<string> unrenewedItems;

        public List<string> UnrenewedItems
        {
            get { return unrenewedItems; }
            set { unrenewedItems = value; }
        }

        private string screenMessage;

        public string ScreenMessage
        {
            get { return screenMessage; }
            set { screenMessage = value; }
        }

        private List<string> printLine = new List<string>() { };

        public List<string> PrintLine
        {
            get { return printLine; }
            set { printLine = value; }
        }

        public RenewAllResponse() { }

        public RenewAllResponse(string _message)
        {
            base.Parse(_message);

            ok = message[2];
            renewedCount = message.ToCharArray(3, 4);
            unrenewedCount = message.ToCharArray(7, 4);
            transactionDate = message.ToCharArray(11, 18);

            institutionId = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], true);

            renewedItems = base.ParseFieldValueList(Sip2Parameter.dicFieldId[enumFieldName.renewed_items.ToString()]);
            unrenewedItems = base.ParseFieldValueList(Sip2Parameter.dicFieldId[enumFieldName.unrenewed_items.ToString()]);

            screenMessage = base.ParseFieldValue(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], false);
            printLine = base.ParseFieldValueList(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()]);
        }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.RenewAllResponse));

            sb.Append(ok);
            sb.Append(renewedCount);
            sb.Append(unrenewedCount);
            sb.Append(transactionDate);

            Append(Sip2Parameter.dicFieldId[enumFieldName.institution_id.ToString()], institutionId);

            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.renewed_items.ToString()], renewedItems);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.unrenewed_items.ToString()], unrenewedItems);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.screen_message.ToString()], screenMessage);
            AppendOptional(Sip2Parameter.dicFieldId[enumFieldName.print_line.ToString()], printLine);

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }


    /// <summary>
    /// 要求自助借还设备重发指令消息[96]
    /// </summary>
    public class RequestScResend : MessageBase
    {
        public RequestScResend() { }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.RequestScResend));

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }

    /// <summary>
    /// 要求图书馆自动化系统重发指令消息[97]
    /// </summary>
    public class RequestAcsResend : MessageBase
    {
        public RequestAcsResend() { }

        private void Build()
        {
            sb = new StringBuilder();

            sb.Append(Sip2Parameter.GetEnumCode(enumCmdId.RequestAcsResend));

            message = sb.ToString();
        }

        public override string ToString()
        {
            Build();

            return message;
        }
    }
}
